﻿using KPI.Api;
using KPI.Data;
using CssdAssistantClient.Views;
using System;
using System.IO;
using System.Security.Cryptography;
using WPF_TY_UI;
using KPI.Entity;

namespace CssdAssistantClient
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : TYWindow
    {
        public MainWindow()
        {
            ViewLogin view = new ViewLogin();
            if (view.ShowDialog() == false)
            {
                Environment.Exit(0);
                return;
            }
            InitializeComponent();
            this.Loaded += MainWindow_Loaded;
        }

        ViewMyWorkbench viewWorkBench = new ViewMyWorkbench();

        private void MainWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            txtUserInfo.Text = $"{KPIData.user.userId} {KPIData.user.userName}({KPIData.user.officeName})";
            this.ctrlContent.Content = viewWorkBench;
            viewWorkBench.Event_SwitchSystem += ViewWorkBench_Event_SwitchSystem;
        }

        private void ViewWorkBench_Event_SwitchSystem(int obj)
        {
            switch (obj)
            {
                case (int)EnumCssdSystems.NaireManager:
                case (int)EnumCssdSystems.TestManager:
                    ViewQuestionNaireHome view = new ViewQuestionNaireHome();
                    this.ctrlContent.Content = view;
                    break;

                default:
                    break;
            }
        }

        private void BtnClick_Close(object sender, System.Windows.RoutedEventArgs e)
        {
            this.Close();
        }

        private void BtnClick_GoWorkBench(object sender, System.Windows.RoutedEventArgs e)
        {
            this.ctrlContent.Content = viewWorkBench;
        }
    }
}
